<template>
  <div>
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
    </BasicTable>
  </div>
</template>
<script lang="ts" setup name="userSign">
import { ActionItem, BasicTable, TableAction } from '@apps/antd-admin/src/components/table';
import { useBaseTable } from '@apps/antd-admin/src/hooks';
import { Api } from './data/api';
import { columns } from './data/data';
import { useMessage } from '@apps/antd-admin/src/hooks/web/useMessage';


const { createMessage, createConfirm } = useMessage();

const { tableContext, handleSuccess } = useBaseTable({
  designScope: 'userGoods-template',
  tableProps: {
    //表格标题
    title: '积分记录',
    //主键字段
    rowKey: 'signHisId',
    //列表接口
    listUrl: Api.page,
    //列定义
    columns,
    useSearchForm:false,
    showActionColumn:false,
    //操作列配置
    actionColumn: {
      width: 240,
      title: '操作',
      dataIndex: 'action',
      slots: { customRender: 'action' },
      fixed: 'right',
    },
    clickToRowSelect: true,
    rowSelection: {
      type: 'radio',
    },
  },
});

const [registerTable, { getForm, setProps, reload }, { rowSelection, hasSelectedRows, selectedRow }] = tableContext;



function handleNowRefund(record) {
  console.info('hasSelectedRows', hasSelectedRows);
  console.info('record', record.canBackCard);
  let vipCardNo = record.vipCardNo;
  let params = {
    userGoodsId: record.userGoodsId,
    vipCardNo: vipCardNo,
    userId: record.userId,
    uesrName: record.userName,
    uesrPhone: record.mobile,
    airportId: record.airportId,
  };
  createConfirm({
    iconType: 'info',
    title: '确认是否现办现退',
    content: '确认现办现退卡号为' + vipCardNo + '的会员卡？',
    onOk: async () => {
      console.info(params);
      handleSuccess(true, {});
    },
    onCancel: async () => {},
  });
}



function setSearchInfoProps(userId) {
  console.info('userId', userId);
  setProps({ searchInfo: { userId: userId } });
}

defineExpose({
  setSearchInfoProps,
});
</script>
